package com.hdsx.jxcsxm.xtgl.bean;

import com.hdsx.jxcsxm.log.bean.DurationBean;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

/**
 * @author 占贤银
 * time 2023/8/21 17:17
 * description 生命之灯因热情而点燃，生命之舟因拼搏而前行
 */
public class UserList {

    private static final UserList userList = new UserList();

    private Vector<DurationPojo> masterVector = new Vector<DurationPojo>();

    private UserList(){}

    public static UserList getInstance() {
        return userList;
    }

    public void addUser(DurationPojo truename){
        if (truename != null) {
            if (masterVector.indexOf(truename) >= 0) {
                return;
            }
            masterVector.addElement(truename);
        }
    }


    public void RemoveUser(DurationPojo master) {
        if (master != null) {
            masterVector.removeElement(master);
        }
    }

    public DurationPojo getDurationBean(String truename){
        for (int i = 0;i < masterVector.size(); i++) {
            if (masterVector.get(i).getTruename().equals(truename)) {
                return masterVector.get(i);
            }
        }
        return null;
    }

    public boolean isExsist(String truename){
        for (int i = 0;i < masterVector.size(); i++) {
            if (masterVector.get(i).getTruename().equals(truename)) {
                return true;
            }
        }
        return false;
    }

    public Enumeration getUserList(){
        return masterVector.elements();
    }

    public Iterator getUserListItera() {
        return masterVector.iterator();
    }

    public int getUserCount() {
        return masterVector.size();
    }


}
